<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="vue.js"></script>
    <title>Document</title>
    <style>
        div {
            width: 500px;
            height: 80px;
            border: 1px solid #000;
            background-color: rgb(43, 223, 236);
            text-align: center;
            line-height: 80px;
            cursor: pointer;
        }

        span {
            display: inline-block;
            width: 100px;
        }
        .color{
            background-color: red;
        }
    </style>
</head>

<body>
    <main id="app">
        <div>
            <span @click='firstClick(index)' :class='{color:second == index}'
             v-for='(name , index) in allName'>{{name.name}}</span>
        </div>
        <label for="">当前页面:</label>
        <span v-text='content'></span>
    </main>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                content: '',
                allName: [
                    { name: 'HOME' },
                    { name: 'NEWS' },
                    { name: 'PROJECTS' },
                    { name: 'SERVICES' },
                    { name: 'CONTACT' }
                ],
                second:' '
            },
            methods:{
                firstClick:function(e){
                    // console.log(e)
                    this.second = e
                    console.log(this.second)
                    this.content = this.allName[e].name
                    console.log(this.content)
                }
            }
        })
    </script>
</body>

</html>